extends Area2D

@export_enum("Colldown", "HitOnce", "DisableHitBox") var HurtBoxType = 0

@onready var disableTimer = $disableTimer
@onready var collision = $CollisionShape2D

signal hurt(damage)

func _on_area_entered(area: Area2D):
	if area.is_in_group("attack"):
		if not area.get("damage") == null:
			match HurtBoxType:
				0:
					collision.call_deferred("set", "disabled", false)
					disableTimer.start()
				1:
					pass
				2:
					if area.has_method("tempdisable"):
						area.tempdisable()
			
			var damage = area.damage
			emit_signal("hurt", damage)
			print("已发出 hurt 信号，damage =", damage)



func _on_disable_timer_timeout() -> void:
	collision.call_deferred("set", "disabled", false)
